//
//  UIView+StartLodingView.m
//  YWToastView
//
//  Created by 余伟 on 16/12/18.
//  Copyright © 2016年 yuwei. All rights reserved.
//

#import "UIView+StartLodingView.h"
#import "UIStartLodingView.h"
#include <objc/runtime.h>
static  const  void *UIStartLodingViewCategorykey= &UIStartLodingViewCategorykey;
@implementation UIView (StartLodingView)
-(void)showLodingMessage:(NSString *)lodingMessage
{
    UIStartLodingView  *lodingView=[self lodingView]?[self lodingView]:[UIStartLodingView sharedLodingView];
    lodingView.frame=self.bounds;
    [lodingView setMessageString:@"正在努力加载中,老板请稍等!!" deslableColor:nil imageString:@"loading"forState:YeeStartIsLodingState];
    [self addSubview:lodingView];
    [self setLodinggView:lodingView];
}
-(void)showNoDataMessage:(NSString *)lodingMessage
{
    UIStartLodingView  *lodingView=[self lodingView]?[self lodingView]:[UIStartLodingView sharedLodingView];
    lodingView.frame=self.bounds;
    [lodingView setMessageString:@"╮(╯_╰)╭ 老板暂时没有数据了 没有数据了没有数据了没有数据了"deslableColor:[UIColor grayColor]imageString:@"icon_jiazaishibai"forState:YeeStartHaveNoDataState];
    [self addSubview:lodingView];
    [self setLodinggView:lodingView];
}
-(void)showErrorMessage:(NSString *)errorMessage method:(SEL)selector
{
    UIStartLodingView  *lodingView=[self lodingView]?[self lodingView]:[UIStartLodingView sharedLodingView];
    lodingView.frame=self.bounds;
    [lodingView setMessageString:@"╮(╯_╰)╭ 老板暂时没有数据了 没有数据了没有数据了没有数据了"deslableColor:[UIColor grayColor]imageString:@"icon_jiazaishibai"forState:YeeStartHaveNoDataState];
    [self addSubview:lodingView];
    [self setLodinggView:lodingView];
}
-(void)showErrorMessage:(NSString *)errorMessage
{
    UIStartLodingView  *lodingView= [self lodingView]?[self lodingView]:[UIStartLodingView sharedLodingView];
    lodingView.frame=self.bounds;
    [lodingView  setMessageString:@"╮(╯_╰)╭ 老板暂时没有网络了"deslableColor:[UIColor grayColor]imageString:@"icon_jiazaishibai"forState:YeeStartHaveNoNetWorkState];
    [self addSubview:lodingView];
    [self setLodinggView:lodingView];
}
-(void)removelodingView
{
    [[self lodingView] removeFromSuperview];
    
}
-(UIStartLodingView*)lodingView
{
    return objc_getAssociatedObject(self, UIStartLodingViewCategorykey);
}
-(void)setLodinggView:(UIStartLodingView*)lodingView
{
     objc_setAssociatedObject(self, UIStartLodingViewCategorykey, lodingView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    
}
@end
